package com.gzc.just.play.last.war.loginserver.sdk.model;

/**
 * 用户平台枚举
 * 对应C++的EUserPlatform枚举
 */
public enum UserPlatform {
    PC(1, "PC"),
    ANDROID(2, "Android"),
    IOS(3, "iOS"),
    WECHAT(4, "WeChat"),
    QQ(5, "QQ"),
    WEIBO(6, "Weibo");
    
    private final int code;
    private final String name;
    
    UserPlatform(int code, String name) {
        this.code = code;
        this.name = name;
    }
    
    public int getCode() {
        return code;
    }
    
    public String getName() {
        return name;
    }
    
    /**
     * 根据代码获取平台枚举
     */
    public static UserPlatform fromCode(int code) {
        for (UserPlatform platform : values()) {
            if (platform.code == code) {
                return platform;
            }
        }
        return PC; // 默认返回PC平台
    }
    
    /**
     * 根据名称获取平台枚举
     */
    public static UserPlatform fromName(String name) {
        for (UserPlatform platform : values()) {
            if (platform.name.equalsIgnoreCase(name)) {
                return platform;
            }
        }
        return PC; // 默认返回PC平台
    }
}